package tianrun.ziguan.api.calculate.config.controller.edge;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tianrun.ziguan.api.calculate.config.dto.request.EdgeSourceLabelParam;
import tianrun.ziguan.api.calculate.config.entity.TEdgeInputInstance;
import tianrun.ziguan.api.calculate.config.service.template.instance.ITEdgeInputInstanceService;
import tianrun.ziguan.api.calculate.config.utils.HttpResponseTools;
import tianrun.ziguan.api.common.core.base.ResultBody;
import tianrun.ziguan.api.common.core.base.ReturnMessage;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("edge/input")
@Api(tags = "边缘端组件")
public class EdgeInputController {
    private final ITEdgeInputInstanceService edgeInputInstanceService;

    public EdgeInputController(ITEdgeInputInstanceService edgeInputInstanceService) {
        this.edgeInputInstanceService = edgeInputInstanceService;
    }
    @ApiOperation(value = "获取边缘端源数据列表")
    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @PostMapping("source/label/list")
    public ResponseEntity<ReturnMessage> sourceLabelList(@RequestBody @Valid EdgeSourceLabelParam param){
        return HttpResponseTools.good(ResultBody.of(edgeInputInstanceService.sourceLabelList(param)));
    }
    @ApiOperation(value = "批量添加")
    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @PostMapping("batch/add")
    public ResponseEntity<ReturnMessage> batchAdd(@RequestBody List<TEdgeInputInstance> list){
        edgeInputInstanceService.batchAdd(list);
        return HttpResponseTools.good();
    }

}
